<?php

namespace backend\controllers;
use common\service\ErrorService;


class ErrorController extends BaseController
{
    //操作日志入库
    public function actionIndex(){
        $error = \Yii::$app->errorHandler->exception;
        $data = [];
        if ($error) {
            $code = $error->getCode();
            $msg = $error->getMessage();
            $file = $error->getFile();
            $line = $error->getLine();
            $err_msg = $msg . " [file: {$file}][line: {$line}][err code:$code.]".
                "[url:{$_SERVER['REQUEST_URI']}][post:".http_build_query($_POST)."]";

        }else{
            $err_msg = $this->get('msg');
        }
        $data['error_msg'] = $err_msg;
        $data['error_type'] = 1;
        ErrorService::Error($data);
        $msg = $this->get('msg','我勒个去，页面被外星人挟持了!');
        return $this->render("index",['msg'=>$msg]);

    }

}